package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: ProjectCollectionServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-12
 * @Version: 1.0
 * Table: pear_project_collection
 * Comment:
 * 项目-收藏表
 */
@Service
public class ProjectCollectionServiceImpl extends ProjectCollectionServiceCustomImpl implements ProjectCollectionService {

    static {
        beanClassNameMap.put("project_collection", "projectCollectionServiceImpl");
        listMethodNameMap.put("project_collection", "listProjectCollection");
        listMethodParameterClassNameMap.put("project_collection", "ProjectCollectionQueryRequest");
        updateMethodNameMap.put("project_collection", "updateProjectCollection");
        updateMethodParameterClassNameMap.put("project_collection", "ProjectCollectionUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addProjectCollection(ProjectCollectionAddRequest request) throws Exception {
        super.fixRequest("project_collection", "add", request);
        return super.addProjectCollection(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateProjectCollection(ProjectCollectionUpdateRequest request) throws Exception {
        ProjectCollection record = null;
        record = projectCollectionMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("project_collection", "update", request, record);
        return super.updateProjectCollection(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteProjectCollection(ProjectCollectionDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<ProjectCollection> list = null;
            ProjectCollectionExample example = new ProjectCollectionExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = projectCollectionMapper.selectByExample(example);
            fixRequest("project_collection", "delete", request, list);
        } else {
            fixRequest("project_collection", "delete", request);
        }
        return super.deleteProjectCollection(request);
    }

    @Override
    public ProjectCollectionQueryResponse queryProjectCollection(ProjectCollectionQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        ProjectCollectionQueryResponse result = super.queryProjectCollection(request);
        checkResult("project_collection", "query", request, result);
        return result;
    }

    @Override
    public List<ProjectCollectionQueryResponse> listProjectCollection(ProjectCollectionQueryRequest request) throws Exception {
        List<ProjectCollectionQueryResponse> list = super.listProjectCollection(request);
        checkResult("project_collection", "list", request, list);
        return list;
    }

    @Override
    public Integer countProjectCollection(ProjectCollectionQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_collection", "count", request);
        return super.countProjectCollection(request);
    }

    @Override
    public BaseStatResponse statProjectCollection(ProjectCollectionQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_collection", "stat", request);
        return super.statProjectCollection(request);
    }

}
